﻿Imports System
Imports System.Collections

Public Class Deck
    Private deck As New ArrayList()
    Private counter As Integer

    Public Sub New()
    End Sub

    Public Sub New(card As Card)
        deck.add(card)
    End Sub

    Public Sub Add(card As Card)
        deck.Add(card)
    End Sub

    Public Sub Shuffle()
        Dim temp As Card
        Dim random As New Random

        For low = 0 To (deck.Count - 1)

            Dim pointer = random.Next(deck.Count - 1)

            temp = deck(low)
            deck(low) = deck(pointer)
            deck(pointer) = temp
        Next
    End Sub

    Public Function Deal() As Card
        Dim card As New Card

        If hasCards() Then
            card = deck(0)
            deck.RemoveAt(0)

            Return card
        Else
            Return Nothing
        End If
    End Function

    Public Function hasCards() As Boolean
        If deck.Count = 0 Then
            Return False
        Else
            Return True
        End If
    End Function

    Public Overrides Function ToString() As String
        Dim s As String = ""

        If hasCards() Then


            For i As Integer = 0 To (deck.Count - 1)
                s += deck(i).ToString & "<br /><br />"
            Next

            Return s

        Else
            Return "Deck is empty"
        End If

    End Function

    Public Sub removeAllCards()
        deck.Clear()
    End Sub
End Class
